//
//  MemberInfoTableViewCell.m
//  Cat
//
//  Created by lushitong on 2018/12/1.
//  Copyright © 2018年 lushitong. All rights reserved.
//

#import "MemberInfoTableViewCell.h"
#import "MemberModel.h"

@interface MemberInfoTableViewCell()

@property (nonatomic, strong) UILabel *topInfoLabel;
@property (nonatomic, strong) UILabel *bottomInfoLabel;

@end

@implementation MemberInfoTableViewCell

- (void)setCellModelData:(id)cellModelData {
	if ([cellModelData isKindOfClass:[MemberModel class]]) {
		MemberModel *model = (MemberModel *)cellModelData;
		self.bottomInfoLabel.text = model.rules;
		NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:model.rules attributes:@{}];
		NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
		[paragraphStyle setLineSpacing:8];//行间距
		[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [model.rules length])];
		[self.bottomInfoLabel setAttributedText:attributedString];
	}
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
	self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
	if (self) {
		self.cellSeparatorStyle = QKUITableViewCellSeparatorStyleNone;
		self.selectionStyle = UITableViewCellSelectionStyleNone;
		[self loadSubviews];
	}
	return self;
}

- (void)loadSubviews {
	[self.contentView addSubviews:@[self.topInfoLabel,self.bottomInfoLabel]];
	
	[self.topInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.top.equalTo(self.contentView.mas_top).offset(kQKFitModuleDecimal(34));
		make.centerX.equalTo(self.contentView.mas_centerX);
	}];
	
	[self.bottomInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.equalTo(self.contentView.mas_left).offset(kQKFitModuleDecimal(16));
		make.right.equalTo(self.contentView.mas_right).offset(-kQKFitModuleDecimal(16));
		make.top.equalTo(self.topInfoLabel.mas_bottom).offset(kQKFitModuleDecimal(16));
	}];
}

#pragma mark----- lazy init -----

- (UILabel *)topInfoLabel {
	if (!_topInfoLabel) {
		_topInfoLabel = [UILabel labelWithText:@"成为超级合伙人" font:[UIFont systemFontOfSize:kQKFitFont(16)] textColor:COLOR_WITH_HEX(0x756D68)];
	}
	return _topInfoLabel;
}

- (UILabel *)bottomInfoLabel {
	if (!_bottomInfoLabel) {
		_bottomInfoLabel = [UILabel labelWithText:@"" font:[UIFont systemFontOfSize:kQKFitFont(12)] textColor:COLOR_WITH_HEX(0x756D68)];
		_bottomInfoLabel.numberOfLines = 0;
	}
	return _bottomInfoLabel;
}

@end
